package lab03.test08;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test08 {
    public static void main(String[] args) {
        String file1="";
        String file2="";
        String file3="";

        //字节流读文件
       FileInputStream file1InputStream=null;
       FileInputStream file2InputStream=null;

        //字节流写文件
        FileOutputStream file3OutputStream=null;

        try {
            file1InputStream=new FileInputStream(file1);
            file2InputStream=new FileInputStream(file2);
            file3OutputStream=new FileOutputStream(file3);

            int data1=0;
            int data2=0;

            while((data1=file1InputStream.read())!=-1
                    ||((data2=file2InputStream.read())!=-1)
                    ){
                file3OutputStream.write(data1);
                file3OutputStream.write(data2);


            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally{

            try {
                file1InputStream.close();
                file2InputStream.close();
                file3OutputStream.close();

            } catch (IOException e) {
                e.printStackTrace();
            }



        }



    }
}
